import numpy as np
import matplotlib.pyplot as plt
import os

fname = 'fig3c.npz'

# load npz file
data = np.load(fname, allow_pickle=True)
print(data.files)
B_up = data['B_up']
B_down = data['B_down']
Rxy_up = data['Rxy_up']
Rxy_down = data['Rxy_down']
B_lin = data['B_lin']
Rxy_asym = data['Rxy_asym']
Temperature = data['Temperature']
indices = data['indices']


# plot raw data
fig, ax = plt.subplots()
fig.suptitle('fig3c raw data')
for i in indices:
    ax.plot(B_up[:,i], Rxy_up[:, i], label='T = ' + str(Temperature[i]) + ' K')
    ax.plot(B_down[:,i], Rxy_down[:, i], label='T = ' + str(Temperature[i]) + ' K')
ax.set_xlabel('$B$ (T)')
ax.set_ylabel('$R_{xy}$ raw')
ax.legend()
plt.show()

# plot processed data
fig, ax = plt.subplots()
fig.suptitle('fig3c antisymmetrized data')
for i in indices:
    ax.plot(B_lin, Rxy_asym[:, i], label='T = ' + str(Temperature[i]) + ' K')
    ax.plot(B_lin, -Rxy_asym[::-1, i], label='T = ' + str(Temperature[i]) + ' K')
ax.set_xlabel('$B$ (T)')
ax.set_ylabel('$R_{xy}$ antisymmetrized')
ax.legend()
plt.show()